package com.ssy.lingxi.product.common.enums;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 物料流程枚举定义
 * @author pengdd
 * @version 2.0.0
 * @date 2022/3/24
 */
public enum MaterialProcessEnum {

    PRODUCT_SERVICE_MATERIALS_ADD_LEVEL_0(1, "product_service_materials_add_level_0", 1,"新增物料--0级",  ""),
    PRODUCT_SERVICE_MATERIALS_ADD_LEVEL_1(2, "product_service_materials_add_level_1", 1,"新增物料--1级", "1-待审核物料（一级）"),
    PRODUCT_SERVICE_MATERIALS_ADD_LEVEL_2(3, "product_service_materials_add_level_2", 1,"新增物料--1级",  "1-待审核物料（一级）1-待审核物料（一级） —>2-待审核物料（二级）"),
    PRODUCT_SERVICE_MATERIALS_CHANGE_OR_ENABLE_LEVEL_0(4, "product_service_materials_change_or_enable_level_0", 2,"变更物料--0级", ""),
    PRODUCT_SERVICE_MATERIALS_CHANGE_OR_ENABLE_LEVEL_1(5, "product_service_materials_change_or_enable_level_1", 2,"变更物料--1级", "1-待审核物料变更（一级）"),
    PRODUCT_SERVICE_MATERIALS_CHANGE_OR_ENABLE_LEVEL_2(6, "product_service_materials_change_or_enable_level_2", 2,"变更物料--2级", "1-待审核物料变更（一级） —>2-待审核物料变更（二级）"),
    ;
    private final Integer code;
    private final  String processKey;
    private final Integer type;
    private final String name;
    private final String remark;
    MaterialProcessEnum(Integer code, String processKey,Integer type, String name,String remark) {
        this.code = code;
        this.processKey = processKey;
        this.type = type;
        this.name = name;
        this.remark = remark;
    }

    public Integer getCode() {
        return code;
    }

    public String getProcessKey() {
        return processKey;
    }

    public Integer getType() {return type;}

    public String getName() {
        return LanguageHolder.getName(this.getClass(), this.code);
    }

    public String getRemark() {
        return LanguageHolder.getName(this.getClass().getSimpleName().concat(".r.").concat(String.valueOf(this.code)));
    }

    /**
     * 根据流程枚举值查询流程名称
     * @param code 流程枚举值
     * @return 流程名称
     */
    public static String getNameByCode(Integer code) {
        return Arrays.stream(MaterialProcessEnum.values()).filter(p -> p.getCode().equals(code)).map(MaterialProcessEnum::getName).findFirst().orElse("");
    }

    /**
     * 根据流程枚举值查询流程步骤描述
     * @param code 流程枚举值
     * @return 流程步骤描述
     */
    public static String getRemarkByCode(Integer code) {
        return Arrays.stream(MaterialProcessEnum.values()).filter(p -> p.getCode().equals(code)).map(MaterialProcessEnum::getRemark).findFirst().orElse("");
    }

}
